Skip to content

Fix GNU LD regex matching CMake status lines as diagnostics (#4910)#4926

Open
Omotola wants to merge 4 commits into
mainfrom
dev/oakeredolu/fix-zephyr-false-diagnostic-4910
Open

Fix GNU LD regex matching CMake status lines as diagnostics (#4910)#4926
Omotola wants to merge 4 commits into
mainfrom
dev/oakeredolu/fix-zephyr-false-diagnostic-4910

Conversation

@Omotola

@Omotola Omotola commented May 5, 2026

Copy link
Copy Markdown
Contributor

Fix GNU LD diagnostic regex matching CMake status lines (#4910)

Problem

The GNU linker diagnostic parser incorrectly matches informational CMake build output as linker diagnostics. For
example, Zephyr build status lines like:

-- Zephyr version: 4.3.0 (/path/to/zephyr), build: v4.3.0

appear in the VS Code Problems panel as errors with source: cmake GNULD, because the regex .*ld in the pattern
matches the ld suffix in build.

Root Cause

Five regex patterns in src/diagnostics/gnu-ld.ts use .*ld to match the linker binary path. This is too broad — it
matches any word ending in ld (e.g., build, child, ould), not just actual linker paths like /usr/bin/ld or
C:\mingw\bin\ld.exe.

Fix

Changed .ld → (?:.[/\])?ld in all five patterns. This requires ld to either:

  • appear at the start of the line, or
  • be preceded by a path separator (/ or )

This ensures only real linker binary paths are matched while rejecting arbitrary words that happen to end in ld.

Testing

Added two new unit tests that reproduce the false positive from #4910:

  • Zephyr version line: -- Zephyr version:
    4.3.0 (/path/to/zephyr), build: v4.3.0
  • Generic CMake status line: -- Some tool version:
    1.0 (/path/to/tool), build: v1.0

Both tests fail before the fix and pass after. All existing GNU LD diagnostic tests continue to pass.

Changes

  • src/diagnostics/gnu-ld.ts — Tightened 5 regex patterns
  • test/unit-tests/diagnostics.test.ts — Added 2 negative test cases
  • CHANGELOG.md — Added bug fix entry

Fixes #4910

Omotola and others added 2 commits May 4, 2026 18:31
Tighten GNU LD diagnostic regex patterns to require a path separator
before 'ld' so words like 'build' no longer falsely match as linker
binary paths. This prevents Zephyr and other CMake status lines from
appearing as spurious problems in the Problems panel.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@hanniavalera

Copy link
Copy Markdown
Contributor

hi! nice fix for the Zephyr case. one concern before merge: the new prefix (?:.*[/\\])?ld requires ld to be preceded by /, \, or start-of-line, which drops cross-compiler linkers invoked by bare name (common in Zephyr / ARM bare-metal / Yocto where the toolchain is on PATH):

arm-none-eabi-ld: cannot find -lfoo
aarch64-linux-gnu-ld: warning: cannot find entry symbol _start

These previously matched via .*ld and now silently disappear from the Problems panel. Affects pattern 4 and pattern 5, and also 1/2/3.

suggested tweak: allow - alongside path separators, and constrain the prefix to a filename-like token so sentences can't match:

(?:[^\s:]*[/\\\-])?ld(?:\.exe)?

this still rejects the Zephyr build: line while catching arm-none-eabi-ld: and friends.

also worth adding a positive test next to the new ones in diagnostics.test.ts for arm-none-eabi-ld: so this can't regress again. the existing gnuld tests only cover /path/to/ld[.exe] style inputs, which is how this gap slipped through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Incorrect gnuld message displayed in Problems panel as diagnostics

3 participants